<?php
/**
 * Created by PhpStorm.
 * User: Aliaksei Lazerka
 * Date: 10/7/14
 * Time: 4:39 PM
 */

namespace controller;

if (!defined('NYMPH_ROOT')) {
  define('NYMPH_ROOT', dirname("../../../" . __FILE__));
  require(NYMPH_ROOT . '/local/loader/kernel/classes/URLClassLoader.php');
}

/**
 * Class BaseWebActor
 * @package controller
 */
abstract class BaseWebActor implements IWebActor
{

  /**
   * @var string path to page body
   */
  private $bodyPath;

  /**
   * @var array with paths to include before executing
   */
  private $includes;

  /**
   * @var string actor name
   */
  private $name;

  /**
   * Perform actor actions
   * @return boolean false if page was not included
   */
  public function execute()
  {
    if ($this->bodyPath) {
      if (!include_once($this->bodyPath)) {
        return false;
      }
    } else {
      return false;
    }
  }

  /**
   * @return string
   */
  public function getBodyPath()
  {
    return $this->bodyPath;
  }

  /**
   * @param string $bodyPath
   */
  public function setBodyPath($bodyPath)
  {
    $this->bodyPath = $bodyPath;
  }

  /**
   * @return array
   */
  public function getIncludes()
  {
    return $this->includes;
  }

  /**
   * @param array $includes
   */
  public function setIncludes($includes)
  {
    $this->includes = $includes;
  }

  /**
   * @param string $include
   */
  public function addInclude($include)
  {
    $this->includes[] = $include;
  }

  /**
   * @return string
   */
  public function getName()
  {
    return $this->name;
  }

  /**
   * @param string $name
   */
  public function setName($name)
  {
    $this->name = $name;
  }
}